﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Hangjing.Model;
using Hangjing.SQLServerDAL;

using System.Text;
using System.Text.RegularExpressions;
using Hangjing.SQLServerDAL.serverinterface;
using Hangjing.WebCommon;

/// <summary>
/// 商户充值
/// </summary>
public partial class AndroidAPI_shop_recharge : System.Web.UI.Page
{

    ShopAPP dal = new ShopAPP();

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();

        string shopid = WebUtility.InputText(Request["shopid"]);

        int rid = Convert.ToInt32(WebUtility.InputText(Request["rid"]));
        PointsInfo model = new Points().GetModel(Convert.ToInt32(shopid));

        decimal price = 0;
        decimal addmoney = 0;
        int award = 0;
        foreach (var item in CacheHelper.GetOrderSourceList())
        {
            if (rid == item.ID)
            {
                price = Convert.ToDecimal(item.classname);

                addmoney = Convert.ToDecimal(item.classname) + item.Status;
                award = item.Status;

                break;
            }
        }

        string orderid = "";
        string tnum = model.Unid.ToString("00000");
        orderid = "s" + tnum + DateTime.Now.ToString("yyMMddHHmmss");


        TogoAddMoneyLog dal = new TogoAddMoneyLog();
        TogoAddMoneyLogInfo addmoneyinfo = new TogoAddMoneyLogInfo();
        addmoneyinfo.AddDate = DateTime.Now;
        addmoneyinfo.AddMoney = addmoney;
        addmoneyinfo.Inve1 = 0;
        addmoneyinfo.Inve2 = orderid;
        addmoneyinfo.PayDate = Convert.ToDateTime("1900-01-01 00:00:00");
        addmoneyinfo.PayState = 0;
        addmoneyinfo.PayType = 5;
        addmoneyinfo.State = award;
        addmoneyinfo.TogoName = "";
        addmoneyinfo.UserId = Convert.ToInt32(shopid);

        dal.AddModel(addmoneyinfo);


        string rs = "{\"orderid\":\"" + orderid + "\",\"paytype\":\"" + 5 + "\",\"payprice\":\"" + price + "\"}";



        Response.Write(rs);
        Response.End();
    }
}
